﻿using Autofac;
using SocialCee.Configuration.Contracts;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace SocialCee.Configuration
{
    /// <summary>
    /// Configuration module
    /// </summary>
    public class ConfigModule : Module
    {
        #region Properties
        public string ExtensionsContainerPath { get; set; }
        public string DBConnectionString { get; set; }
        #endregion

        /// <summary>
        /// Loads configuration and creates <see cref="Config"/> object
        /// </summary>
        /// <param name="builder"></param>
        protected override void Load(ContainerBuilder builder)
        {
            if (Directory.Exists(ExtensionsContainerPath))
            {
                builder.RegisterInstance<Config>(new Config() 
                { 
                    ExtensionsContainerPath = ExtensionsContainerPath,
                    DBConnectionString = DBConnectionString
                });
            }
        }
    }
}
